<%@page language="java" pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt"%>

<!DOCTYPE html>
<html>
	<head>
		<title>My JSP 'detailInformation.jsp' starting page</title>

		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
		<script type="text/javascript"
			src="http://api.map.baidu.com/api?v=1.3"></script>
	</head>

	<body>
		<div>
			<div style="width: 520px; height: 340px; border: 1px solid gray"
				id="container"></div>
			<div>
				<div>
					<c:forEach items="${information.addresses}" var="address">
						<li>
							<c:choose>
								<c:when test="${address.type eq '01'}">
									始发地信息：
								</c:when>
								<c:when test="${address.type eq '03'}">
									目的地信息：
								</c:when>
							</c:choose>
							${address.province }${address.city }${address.district }${address.street }${address.streetNumber }
						<li>
					</c:forEach>
						<ul>
							<li>
								出发时间：<fmt:formatDate value="${information.departureTime }" type="both" pattern="EEEE, MMMM d, yyyy HH:mm Z"/>
							</li>
							<c:if test="${!empty information.car.carId}">
								<li>
									车辆类型：${information.car.carType }
								</li>
								<li>
									车牌号：${information.car.carLicense }
								</li>
							</c:if>
						</ul>
				</div>
			</div>
			<form action="bookSeat.do" method="post">
				<input type="hidden" value="${information.informationId}"
					name="informationId" />
				<input type="submit" value="预订" />
			</form>
		</div>
		<br>
	</body>
</html>


<script type="text/javascript">
	var map = new BMap.Map("container");
	map.centerAndZoom(new BMap.Point(116.404, 39.915), 14);
	
	<c:forEach items="${information.addresses}" var="address">
		<c:if test="${address.type == '01'}">
			var departureX = "${address.x}";
			var departureY = "${address.y}";
		</c:if>
		<c:if test="${address.type == '03'}">
			var destinationX = "${address.x}";
			var destinationY = "${address.y}";
		</c:if>
	</c:forEach>
	
	var startPoint = new BMap.Point(departureX, departureY);
	var endPoint = new BMap.Point(destinationX, destinationY);

	var driving = new BMap.DrivingRoute(map, {
		renderOptions : {
			map : map,
			autoViewport : true
		}
	});
	driving.search(startPoint, endPoint);
	
</script>